<?php
/**
 * 后台管理
 */
namespace App\Http\Controllers\Admin;

use App\Models\AdminUser;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class AdminController extends Controller
{
    //数据模型定义
    protected $adminModel;

    //构造函数实例化数据模型
    public function __construct()
    {
        $this->adminModel = new AdminUser();

    }
    public function index(){
        return view('admin.admin.getlist');
    }

    //后台用户列表
    public function getList(Request $request){
        $params = [
            'where'=>[['is_delete',1]],
            'field'=>['id','name','email','mobile','password','login_total','sex','login_ip','status','is_delete','created_at','updated_at'],
            'order'=>'created_at',
            'getfield'=>false,
            'page'=>$request->input('page')-1,
            'limit'=>$request->input('limit')
        ];
        $name = $request->input("name");
        if(!empty($name)){
            $params['where'][1]=['name','like',"'%".$name."%'"];
        }
        $res = $this->adminModel->getlist($params);
        return response()->json(array('code'=>0,'data'=>$res ? $res : []));

    }
    public function add(){
        return view('admin.admin.add');
    }
}
